package com.siyu.tickets.entity;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.siyu.tickets.entity.base.BaseProduct;

public class Product extends BaseProduct {

	private static final long serialVersionUID = 4961014282326781730L;

	public static final String DOT_CITYS = ",";

	public void setCities(List<Integer> cities) {
		StringBuffer sCity = new StringBuffer();
		if (cities == null || cities.isEmpty()) {
			return;
		}
		for (Integer ct : cities) {
			sCity.append(ct).append(DOT_CITYS);
		}
		sCity.deleteCharAt(sCity.length() - 1);
		this.setCityIds(sCity.toString());
	}

	public List<Integer> getCities() {
		if (StringUtils.isBlank(this.getCityIds())) {
			return null;
		}
		List<Integer> cities = new ArrayList<Integer>();
		String[] rs = this.getCityIds().split(DOT_CITYS);
		for (String cityId : rs) {
			cities.add(Integer.valueOf(cityId));
		}
		return cities;
	}

	/*public void setCities(String[] cities) {
		StringBuffer sCity = new StringBuffer();
		if (cities == null || cities.length == 0) {
			return;
		}
		for (String ct : cities) {
			sCity.append(ct).append(DOT_CITYS);
		}
		sCity.deleteCharAt(sCity.length() - 1);
		this.setCityIds(sCity.toString());
	}

	public String[] getCities() {
		if (StringUtils.isBlank(this.getCityIds())) {
			return null;
		}
		return this.getCityIds().split(DOT_CITYS);
	}*/
}
